package com.example.personordersystem.util.customwidget;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemLongClickListener;

import android.widget.ScrollView;

public class CustomListViewScrollview extends ScrollView implements OnGestureListener{
	private CustomListView listView;
	private CustomAdapter mSelfAdapter;
	Context context;
	AttributeSet attrs;
	private GestureDetector detector;
	public CustomListViewScrollview(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.context = context;
		this.attrs = attrs;
		listView = new CustomListView(context, attrs);
		this.addView(listView);
		detector=new GestureDetector(this);
	}
	  @Override
	    public boolean onTouchEvent(MotionEvent event) 
	    {
	        detector.onTouchEvent(event);
	        return super.onTouchEvent(event);
	    }
	 
	public CustomListViewScrollview(Context context) {
		super(context);
		listView = new CustomListView(context, attrs);
		this.addView(listView);
	}
	public CustomAdapter getSelfAdapter() {
		return mSelfAdapter;
	}
	public void setAdapter(CustomAdapter selfAdapter) {
		listView.setAdapter(selfAdapter);
		listView.buildList();
	}
	public int getItemId() {
		return listView.getId();
	}
	@Override
	public boolean onDown(MotionEvent e) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
			float velocityY) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void onLongPress(MotionEvent e) {

		Log.v("onLongPress", getItemId()+"");
		
	}

	@Override
	public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
			float distanceY) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void onShowPress(MotionEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean onSingleTapUp(MotionEvent e) {
		// TODO Auto-generated method stub
		return false;
	}

}
